<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <div class="section">
                <h1>Pesquisando</h1>
                <h:form id="formCorrector">
                    <p:growl id="msg" life="3000"/>
                    <div class="container_24 clearfix">
                        <p:panel header="Filtros">
                            <f:validateBean disabled="true" >
                                <p:outputLabel value="Nome:" styleClass="grid_3" />
                                <p:inputText styleClass="grid_19 ajustInput" value="#{managerSearchCorrector.corrector.name}"  />
                                <div class="clear-both"/>

                                <p:outputLabel value="Creci:" styleClass="grid_3" />
                                <p:inputText styleClass="grid_8" value="#{managerSearchCorrector.corrector.creci}"  />

                                <p:outputLabel value="CPF:" styleClass="grid_3" />
                                <p:inputMask mask="999.999.999-99" styleClass="grid_8" value="#{managerSearchCorrector.corrector.cpf}" />
                            </f:validateBean>
                            <div class="clear"/>
                        </p:panel>

                        <div class="buttonAction">
                            <p:commandButton value="Pesquisar"
                                             actionListener="#{managerSearchCorrector.search()}"
                                             update="@form, tableCorrectors"
                                             icon="ui-icon-search"/>
                            <p:commandButton value="Limpar" icon="ui-icon-close"
                                             actionListener="#{managerSearchCorrector.clear()}"
                                             update="@form"  />

                        </div>

                        <p:dataTable id="tableCorrectors" var="c" value="#{managerSearchCorrector.correctors}" 
                                     styleClass="grid_24"
                                     rowIndexVar="rowid"
                                     rows="5" paginator="true"  
                                     paginatorPosition="bottom"
                                     emptyMessage="Nenhum registro">  
                            <f:facet name="header">
                                Construtoras
                            </f:facet>
                            <p:column headerText="Nome" width="600">  
                                <h:outputText value="#{c.name}"/>
                            </p:column>  
                            <p:column headerText="Creci">  
                                <h:outputText value="#{c.creci}"/>
                            </p:column>
                            <p:column headerText="CPF">  
                                <h:outputText value="#{c.cpf}"/>
                            </p:column>
                            <p:column headerText="Ação" width="75">
                                <p:button  style="width: 20px; height: 20px;" 
                                           update="@form" title="editar"
                                           href="editcorrector.xhtml?correctorId=#{c.id}" 

                                           icon="ui-icon-pencil"/>
                                <p:button  style="width: 20px; height: 20px;" 
                                           update="@form" title="visualizar"
                                           href="viewcorrector.xhtml?correctorId=#{c.id}" 
                                           icon="ui-icon-zoomin"/>
                                <p:commandButton  style="width: 20px; height: 20px;" 
                                                  update="@form" title="excluir"
                                                  oncomplete="dlg.show()"
                                                  icon="ui-icon-trash">
                                    <f:setPropertyActionListener target="#{managerSearchCorrector.removeCorrector}" value="#{c}" />
                                </p:commandButton>
                            </p:column>
                        </p:dataTable> 
                             <div class="buttonAction">
                                <p:button value="Voltar"
                                          href="indexcorrector.xhtml"
                                          icon="ui-icon-arrowreturnthick-1-w"/>
                               

                            </div>

                        <p:dialog id="modalDialog" header="Confirmação de remoção" widgetVar="dlg" modal="true" height="100">
                            <h:outputText value="Tem certeza que deseja remover este corretor ?" />
                            <div class="buttonAction">
                                <p:commandButton value="Sim"
                                                 actionListener="#{managerSearchCorrector.remove()}"
                                                 update="@form"
                                                 icon="ui-icon-check"/>
                                <p:commandButton value="Não" icon="ui-icon-close"
                                                 oncomplete="dlg.hide()"
                                                  />

                            </div>

                        </p:dialog>
                    </div>
                </h:form>
            </div>
        </ui:define>
    </ui:composition>

</html>
